﻿@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: true *@

@inherits LogDashboard.Views.RazorPage

@using System.Collections.Generic
@using LogDashboard.Models

<div class="table-responsive">
    <table class="table row mx-0 table-hover table-expandable">
        <thead class="w-100">
            <tr class="row mx-0">
                <th class="col-1">Id</th>
                <th class="col-3">Logger</th>
                <th class="col-1">级别</th>
                <th class="col-4">消息</th>
                <th class="col-2">时间</th>
            </tr>
        </thead>
        <tbody class="w-100">
            @foreach (var item in (IEnumerable<ILogModel>)ViewData["Model"])
            {
            <tr class="row mx-0">
                <td class="col-1"><a href="javascript:void(0);" onclick="logInfo('@item.Id.ToString()')">@item.Id.ToString()</a></td>
                <td class="col-3"><span>@item.Logger</span></td>
                @{
                        if (item.Level== LogLevelConst.Error)
                        {
                            <div class="modal fade" id="@item.Id.ToString()">
                                <div class="modal-dialog modal-lg" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header bg-danger border-0"><h5 class="modal-title text-white">Exception</h5><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div><div class="modal-body">
                                            <pre>@item.Exception</pre>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <td class="col-1"><button class="btn btn-outline-@item.Level.ToUpper()" onclick='$("#@item.Id.ToString()").modal();'>@item.Level.ToUpper()</button></td>
                        }
                        else
                        {
                            <td class="col-1"><button class="btn btn-outline-@item.Level.ToUpper()">@item.Level.ToUpper()</button></td>
                        }
                }
                <td class="col-4">
                    @{
                            var message = item.Message;
                            if (message.Length > 90)
                            {
                                message = message.Substring(0, 90) + "........";
                            }
                    }
                    @message
                </td>
                <td class="col-2">@item.LongDate.ToString("yyyy-MM-dd HH:mm:ss")</td>
            </tr>
            <tr class="row mx-0">
                <td colspan="10" style="width: 100%">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <tbody>
                                <tr>
                                    <td>Id</td>
                                    <td class="text-nowrap">@item.Id.ToString()</td>
                                </tr>
                                <tr>
                                    <td>时间</td>
                                    <td class="text-nowrap">@item.LongDate.ToString("yyyy-MM-dd HH:mm:ss")</td>
                                </tr>
                                <tr>
                                    <td>级别</td>
                                    <td class="text-nowrap"><button class="btn btn-outline-@item.Level">@item.Level</button></td>
                                </tr>
                                <tr>
                                    <td>Logger</td>
                                    <td class="text-nowrap">@item.Logger</td>
                                </tr>
                                <tr>
                                    <td>消息</td>
                                    <td class="text-nowrap">@item.Message</td>
                                </tr>

                            </tbody>
                        </table>
                        <div class="card">
                            <div class="card-header bg-light">
                                堆栈信息
                            </div>
                            <div class="card-body">
                                <pre>@item.Exception</pre>
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
            }
        </tbody>
    </table>
</div>